package com.wxq.yaoxia;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.wxq.yaoxia.mainborad.YXMainboradActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;

public class YXHelpActivity extends YXBaseActivity {

	ListView aboutLV ;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentViewWithTopbar(R.layout.yx_about, R.layout.yx_topbar);
		aboutLV = (ListView) findViewById(R.id.aboutLV);
		setAboutListView();
		aboutLV.setOnItemClickListener(
				new OnItemClickListener()
				{

					@Override
					public void onItemClick(AdapterView<?> parent, View view,
							int position, long id) {
						// TODO Auto-generated method stub
						Intent intent = new Intent();
						
						switch (position) {
						case 0:
							intent.putExtra("text", R.string.help1);
							intent.putExtra("image", 0);
							break;
						
						case 1:
							intent.putExtra("text", R.string.help2);
							intent.putExtra("image", 0);
							break;
							
						case 2:
							intent.putExtra("text", R.string.help3);
							intent.putExtra("image", 0);
							break;
							
						case 3:
							intent.putExtra("text", R.string.help4);
							intent.putExtra("image", 0);
							break;
						case 4:
							intent.putExtra("text", R.string.help5);
							intent.putExtra("image", 0);
							break;
						case 5:
							intent.putExtra("text", R.string.help6);
							intent.putExtra("image", 0);
							break;
						case 6:
							intent.putExtra("text", R.string.help7);
							intent.putExtra("image", 0);
							break;
						case 7:
							intent.putExtra("text", R.string.help8);
							intent.putExtra("image", 0);
							break;
						case 8:
							intent.putExtra("text", R.string.help9);
							intent.putExtra("image", 0);
							break;
						case 9:
							intent.putExtra("text", R.string.help10);
							intent.putExtra("image", 0);
							break;
						default:
							break;
						}
						
						intent.setClass(YXHelpActivity.this, YXAboutDetailActivity.class);
						YXHelpActivity.this.startActivity(intent);
					}
				});
	}

	@Override
	public void setTopBarButtonListener() {
		Button leftBtn = (Button) findViewById(R.id.btnLeft);
    	Button rightBtnButton = (Button) findViewById(R.id.btnRight);
    	TextView centerTV = (TextView) findViewById(R.id.centerTV);
    	
    	leftBtn.setVisibility(View.VISIBLE);
    	leftBtn.setText("返回");
    	leftBtn.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		});
    	rightBtnButton.setVisibility(View.VISIBLE);
//    	rightBtnButton.setText("药");
    	rightBtnButton.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent();
				intent.setClass(YXHelpActivity.this, YXMainboradActivity.class);
				YXHelpActivity.this.startActivity(intent);
			}
		});
    	centerTV.setVisibility(View.VISIBLE);
    	centerTV.setText("帮助");
	}

	public List< Map<String, String> > getAboutData() {
		List< Map<String, String> > list = new ArrayList<Map<String,String>>();
		    Map<String, String> temp1 = new HashMap<String, String>();
		    temp1.put("name", "如何查看药品适应症及使用方法");
		    Map<String, String> temp2 = new HashMap<String, String>();
		    temp2.put("name", "如何查看药品副作用");
		    Map<String, String> temp3 = new HashMap<String, String>();
		    temp3.put("name", "如何查看服药注意事项");
		    Map<String, String> temp4 = new HashMap<String, String>();
		    temp4.put("name", "如何查看药物相互作用");
		    Map<String, String> temp5 = new HashMap<String, String>();
		    temp5.put("name", "如何查看小贴士");
		    Map<String, String> temp6 = new HashMap<String, String>();
		    temp6.put("name", "如何查看替代药品");
		    Map<String, String> temp7 = new HashMap<String, String>();
		    temp7.put("name", "警告信息的查看");
		    Map<String, String> temp8 = new HashMap<String, String>();
		    temp8.put("name", "如何查看某一特定疾病");
		    Map<String, String> temp9 = new HashMap<String, String>();
		    temp9.put("name", "如何查看疾病症状");
		    Map<String, String> temp10 = new HashMap<String, String>();
		    temp10.put("name", "如何查看疾病治疗药物");
		    
			list.add(temp1);
			list.add(temp2);
			list.add(temp3);
			list.add(temp4);
			list.add(temp5);
			list.add(temp6);
			list.add(temp7);
			list.add(temp8);
			list.add(temp9);
			list.add(temp10);
		
		return list;
	}
	
	public void setAboutListView() {
		List<Map<String, String>> list = getAboutData();
		
		SimpleAdapter simpleAdapter = new SimpleAdapter(this, list, R.layout.shool_item, new String []{"name"}, new int []{android.R.id.text1});
		aboutLV.setAdapter(simpleAdapter);
	}
}
